
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>栅格数据投影转换 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="栅格数据裁剪.html" />
    
    
    <link rel="prev" href="读取HDF或者NetCDF格式的栅格数据.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../Python基础/">
            
                <a href="../../Python基础/">
            
                    
                    Python基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../Python基础/Python环境搭建及基本数据类型.html">
            
                <a href="../../Python基础/Python环境搭建及基本数据类型.html">
            
                    
                    Python环境搭建及基本数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../Python基础/运算符及字符串.html">
            
                <a href="../../Python基础/运算符及字符串.html">
            
                    
                    运算符及字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../Python基础/序列与字典.html">
            
                <a href="../../Python基础/序列与字典.html">
            
                    
                    序列与字典
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../../Python基础/流程控制语句.html">
            
                <a href="../../Python基础/流程控制语句.html">
            
                    
                    流程控制语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../../Python基础/函数.html">
            
                <a href="../../Python基础/函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../../Python基础/面向对象编程初识.html">
            
                <a href="../../Python基础/面向对象编程初识.html">
            
                    
                    面向对象编程初识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../../Python基础/面向对象编程高级.html">
            
                <a href="../../Python基础/面向对象编程高级.html">
            
                    
                    面向对象编程高级
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../../Python基础/Python科学计算.html">
            
                <a href="../../Python基础/Python科学计算.html">
            
                    
                    Python科学计算
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../../Python基础/空间数据处理环境搭建.html">
            
                <a href="../../Python基础/空间数据处理环境搭建.html">
            
                    
                    空间数据处理环境搭建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../空间数据基础/">
            
                <a href="../../空间数据基础/">
            
                    
                    空间数据基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../空间数据基础/空间参考系统.html">
            
                <a href="../../空间数据基础/空间参考系统.html">
            
                    
                    空间参考系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../空间数据基础/地图投影.html">
            
                <a href="../../空间数据基础/地图投影.html">
            
                    
                    地图投影
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../空间数据基础/空间数据.html">
            
                <a href="../../空间数据基础/空间数据.html">
            
                    
                    空间数据
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../">
            
                <a href="../">
            
                    
                    GDAL空间数据处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../GDAL简介.html">
            
                <a href="../GDAL简介.html">
            
                    
                    GDAL简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../GDAL数据基本操作.html">
            
                <a href="../GDAL数据基本操作.html">
            
                    
                    GDAL数据基本操作
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.2.1" data-path="打开栅格数据的正确方式.html">
            
                <a href="打开栅格数据的正确方式.html">
            
                    
                    打开栅格数据的正确方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.2" data-path="栅格数据格式转换.html">
            
                <a href="栅格数据格式转换.html">
            
                    
                    栅格数据格式转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.3" data-path="栅格数据创建与保存.html">
            
                <a href="栅格数据创建与保存.html">
            
                    
                    栅格数据创建与保存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.4" data-path="读取HDF或者NetCDF格式的栅格数据.html">
            
                <a href="读取HDF或者NetCDF格式的栅格数据.html">
            
                    
                    读取HDF或者NetCDF格式的栅格数据
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.2.5" data-path="栅格数据投影转换.html">
            
                <a href="栅格数据投影转换.html">
            
                    
                    栅格数据投影转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.6" data-path="栅格数据裁剪.html">
            
                <a href="栅格数据裁剪.html">
            
                    
                    栅格数据裁剪
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.7" data-path="打开Shapefile文件的正确方式.html">
            
                <a href="打开Shapefile文件的正确方式.html">
            
                    
                    打开Shapefile文件的正确方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.8" data-path="创建Shapefile文件并写入数据.html">
            
                <a href="创建Shapefile文件并写入数据.html">
            
                    
                    创建Shapefile文件并写入数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.9" data-path="矢量数据投影转换.html">
            
                <a href="矢量数据投影转换.html">
            
                    
                    矢量数据投影转换
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Fiona矢量数据处理/REDAME.md">
            
                <span>
            
                    
                    Fiona矢量数据处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.3.1" data-path="../Fiona矢量数据处理/Fiona简介及Shapefile数据读取.html">
            
                <a href="../Fiona矢量数据处理/Fiona简介及Shapefile数据读取.html">
            
                    
                    Fiona简介及Shapefile数据读取
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3.2" data-path="../Fiona矢量数据处理/使用Fiona创建Shapefile矢量数据.html">
            
                <a href="../Fiona矢量数据处理/使用Fiona创建Shapefile矢量数据.html">
            
                    
                    使用Fiona创建Shapefile矢量数据
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../Rasterio栅格数据处理/README.md">
            
                <span>
            
                    
                    Rasterio栅格数据处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.4.1" data-path="../Rasterio栅格数据处理/使用Rasterio读取栅格数据.html">
            
                <a href="../Rasterio栅格数据处理/使用Rasterio读取栅格数据.html">
            
                    
                    使用Rasterio读取栅格数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4.2" data-path="../Rasterio栅格数据处理/使用Rasterio创建栅格数据.html">
            
                <a href="../Rasterio栅格数据处理/使用Rasterio创建栅格数据.html">
            
                    
                    使用Rasterio创建栅格数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4.3" data-path="../Rasterio栅格数据处理/使用Rasterio做投影变换.html">
            
                <a href="../Rasterio栅格数据处理/使用Rasterio做投影变换.html">
            
                    
                    使用Rasterio做投影变换
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >栅格数据投影转换</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6805;&#x683C;&#x6570;&#x636E;&#x6295;&#x5F71;&#x8F6C;&#x6362;">&#x6805;&#x683C;&#x6570;&#x636E;&#x6295;&#x5F71;&#x8F6C;&#x6362;</h1>
<p>&#x4F5C;&#x8005;&#xFF1A;&#x963F;&#x632F;</p>
<p>&#x90AE;&#x7BB1;&#xFF1A;tanzhenyugis@163.com</p>
<p>&#x535A;&#x5BA2;&#xFF1A;<a href="https://blog.csdn.net/theonegis/article/details/80089375" target="_blank">https://blog.csdn.net/theonegis/article/details/80089375</a></p>
<p>&#x4FEE;&#x6539;&#x65F6;&#x95F4;&#xFF1A;2018-06-01</p>
<p>&#x58F0;&#x660E;&#xFF1A;&#x672C;&#x6587;&#x4E3A;&#x535A;&#x4E3B;&#x539F;&#x521B;&#x6587;&#x7AE0;&#xFF0C;&#x8F6C;&#x8F7D;&#x8BF7;&#x6CE8;&#x660E;&#x539F;&#x6587;&#x51FA;&#x5904;</p>
<hr>
<h2 id="&#x4F7F;&#x7528;gdal&#x63D0;&#x4F9B;&#x7684;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#x8FDB;&#x884C;&#x8F6C;&#x6362;">&#x4F7F;&#x7528;GDAL&#x63D0;&#x4F9B;&#x7684;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#x8FDB;&#x884C;&#x8F6C;&#x6362;</h2>
<p>GDAL&#x63D0;&#x4F9B;&#x4E86;<code>gdalwarp</code>&#x547D;&#x4EE4;&#x53EF;&#x4EE5;&#x65B9;&#x4FBF;&#x5730;&#x8BA9;&#x6211;&#x4EEC;&#x8FDB;&#x884C;&#x5F71;&#x50CF;&#x62FC;&#x63A5;&#xFF0C;&#x91CD;&#x6295;&#x5F71;&#xFF0C;&#x88C1;&#x526A;&#xFF0C;&#x683C;&#x5F0F;&#x8F6C;&#x6362;&#x7B49;&#x529F;&#x80FD;</p>
<p>&#x6BD4;&#x5982;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5C06;MODIS&#x6570;&#x636E;&#x7684;Sinusoidal&#x6295;&#x5F71;&#x8F6C;&#x4E3A;UTM&#x6295;&#x5F71;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x64CD;&#x4F5C;&#x3002;</p>
<p>&#x6211;&#x9700;&#x8981;&#x8F6C;&#x6362;&#x7684;&#x5730;&#x533A;&#x4F4D;&#x4E8E;UTM&#x7684;49&#x5EA6;&#x5E26;&#x5185;&#xFF0C;&#x6211;&#x67E5;&#x770B;&#x4E86;&#x4E00;&#x4E0B;&#x5176;EPSG&#x7684;&#x7F16;&#x7801;&#x4E3A;&#xFF1A;EPSG:32649&#xFF08;WGS 84 / UTM zone 49N&#xFF09;</p>
<p>&#x6CE8;&#xFF1A;&#x63A8;&#x8350;&#x5927;&#x5BB6;&#x4E00;&#x4E2A;&#x7F51;&#x7AD9;&#xFF0C;&#x53EF;&#x4EE5;&#x67E5;&#x9605;&#x5404;&#x79CD;&#x6295;&#x5F71;&#x7684;&#x5B9A;&#x4E49;&#xFF1A;<a href="http://spatialreference.org" target="_blank">http://spatialreference.org</a></p>
<p>&#x7136;&#x540E;&#xFF0C;&#x7EC8;&#x7AEF;&#x4E2D;&#x6267;&#x884C;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#xFF1A;</p>
<p><code>gdalinfo MOD09A1.A2017361.h28v06.006.2018005034659.hdf</code> &#xFF08;&#x7528;&#x4E8E;&#x67E5;&#x770B;MODIS&#x6570;&#x636E;&#x4E2D;&#x7684;&#x6CE2;&#x6BB5;&#x540D;&#x79F0;&#x4E0E;&#x5730;&#x5740;&#xFF0C;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x53EA;&#x8F6C;&#x6362;&#x7B2C;&#x4E00;&#x6CE2;&#x6BB5;&#xFF09;</p>
<p><code>gdalwarp -t_srs EPSG:32649 HDF4_EOS:EOS_GRID:&quot;MOD09A1.A2017361.h28v06.006.2018005034659.hdf&quot;:MOD_Grid_500m_Surface_Reflectance:sur_refl_b01 MODSI_WARP_32649.tif</code>&#xFF08;<code>-t_srs</code>&#x53C2;&#x6570;&#x7528;&#x4E8E;&#x6307;&#x5B9A;&#x8F93;&#x51FA;&#x6295;&#x5F71;&#x4FE1;&#x606F;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;EPSG&#xFF0C;&#x6216;&#x8005;OGC WKT&#xFF0C;&#x6216;&#x8005;PROJ4&#x683C;&#x5F0F;&#xFF0C;&#x540E;&#x9762;&#x5206;&#x522B;&#x662F;&#x8F93;&#x5165;&#x6570;&#x636E;&#x548C;&#x8F93;&#x51FA;&#x6570;&#x636E;&#x6587;&#x4EF6;&#x540D;&#xFF09;</p>
<h2 id="&#x4F7F;&#x7528;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x8F6C;&#x6362;">&#x4F7F;&#x7528;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x8F6C;&#x6362;</h2>
<p>&#x4F7F;&#x7528;&#x547D;&#x4EE4;&#x884C;&#x8F6C;&#x6362;&#xFF0C;&#x5F53;&#x7136;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;&#x5566;&#xFF1A;</p>
<p>&#x7B2C;&#x4E00;&#xFF0C;&#x76F4;&#x63A5;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x8C03;&#x7528;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#x7684;&#x63A5;&#x53E3;&#xFF08;&#x6BD4;&#x8F83;&#x61D2;&#x7684;&#x4EBA;&#xFF0C;&#x50CF;&#x6211;&#xFF0C;&#x5F53;&#x7136;&#x76F4;&#x63A5;&#x7528;&#x7B2C;&#x4E00;&#x79CD;&#x5566;&#xFF0C;&#x6709;&#x73B0;&#x6210;&#x7684;&#x5DE5;&#x5177;&#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x7528;&#xFF09;&#xFF1B;</p>
<p>&#x7B2C;&#x4E8C;&#xFF0C;&#x81EA;&#x5DF1;&#x505A;&#x6295;&#x5F71;&#x8F6C;&#x6362;&#x4E4B;&#x540E;&#x7684;&#x5750;&#x6807;&#x8BA1;&#x7B97;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x8BA1;&#x7B97;&#x91CD;&#x6295;&#x5F71;&#x4E4B;&#x540E;&#x7684;GeoTransform&#x53C2;&#x6570;&#xFF0C;&#x6709;&#x4E86;GeoTransform&#x53C2;&#x6570;&#x4EE5;&#x53CA;&#x6295;&#x5F71;&#x7684;&#x5B9A;&#x4E49;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>SetGeoTransform()</code>&#x548C;<code>SetProjection()</code>&#x6295;&#x5F71;&#x8F6C;&#x6362;&#x4E86;.</p>
<p>&#x4E0B;&#x9762;&#x6211;&#x7ED9;&#x51FA;&#x5177;&#x4F53;&#x7684;&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#xFF1A;</p>
<p>&#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;&#x76F4;&#x63A5;&#x8C03;&#x7528;<code>gdal.Warp()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x5BF9;<code>gdalwarp</code>&#x547D;&#x4EE4;&#x7684;&#x5C01;&#x88C5;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8F93;&#x51FA;&#x6587;&#x4EF6;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8F93;&#x5165;&#x6587;&#x4EF6;&#x6216;&#x8005;&#x8F93;&#x5165;&#x7684;Dataset&#xFF0C;&#x540E;&#x9762;&#x7684;&#x90FD;&#x662F;&#x53EF;&#x9009;&#x53C2;&#x6570;&#xFF08;dstSRS&#x53C2;&#x6570;&#x6307;&#x5B9A;&#x8F93;&#x51FA;&#x6295;&#x5F71;&#xFF09;</p>
<pre><code class="lang-Python"><span class="hljs-keyword">from</span> osgeo <span class="hljs-keyword">import</span> gdal

root_ds = gdal.Open(<span class="hljs-string">&apos;MOD09A1.A2017361.h28v06.006.2018005034659.hdf&apos;</span>)
<span class="hljs-comment"># &#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x662F;&#x4E00;&#x4E2A;list&#xFF0C;list&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x662F;&#x4E00;&#x4E2A;tuple&#xFF0C;&#x6BCF;&#x4E2A;tuple&#x4E2D;&#x5305;&#x542B;&#x4E86;&#x5BF9;&#x6570;&#x636E;&#x96C6;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x5143;&#x6570;&#x636E;&#x7B49;&#x7684;&#x63CF;&#x8FF0;&#x4FE1;&#x606F;</span>
<span class="hljs-comment"># tuple&#x4E2D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x63CF;&#x8FF0;&#x7684;&#x662F;&#x6570;&#x636E;&#x5B50;&#x96C6;&#x7684;&#x5168;&#x8DEF;&#x5F84;</span>
ds_list = root_ds.GetSubDatasets()

<span class="hljs-comment"># &#x53D6;&#x51FA;&#x7B2C;1&#x4E2A;&#x6570;&#x636E;&#x5B50;&#x96C6;&#xFF08;MODIS&#x53CD;&#x5C04;&#x7387;&#x4EA7;&#x54C1;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x6CE2;&#x6BB5;&#xFF09;&#x8FDB;&#x884C;&#x8F6C;&#x6362;</span>
<span class="hljs-comment"># &#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8F93;&#x51FA;&#x6570;&#x636E;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8F93;&#x5165;&#x6570;&#x636E;&#xFF0C;&#x540E;&#x9762;&#x53EF;&#x4EE5;&#x8DDF;&#x591A;&#x4E2A;&#x53EF;&#x9009;&#x9879;</span>
gdal.Warp(<span class="hljs-string">&apos;reprojection.tif&apos;</span>, ds_list[<span class="hljs-number">0</span>][<span class="hljs-number">0</span>], dstSRS=<span class="hljs-string">&apos;EPSG:32649&apos;</span>)

<span class="hljs-comment"># &#x5173;&#x95ED;&#x6570;&#x636E;&#x96C6;</span>
root_ds = <span class="hljs-keyword">None</span>
</code></pre>
<p>&#x5728;&#x4ECB;&#x7ECD;&#x7B2C;&#x4E8C;&#x79CD;&#x65B9;&#x6CD5;&#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x6709;&#x5FC5;&#x8981;&#x56DE;&#x5FC6;&#x4E00;&#x4E0B;&#x4E4B;&#x524D;&#x8BF4;&#x8FC7;&#x7684;GDAL&#x53CD;&#x5C04;&#x53D8;&#x6362;&#x7684;&#x516D;&#x53C2;&#x6570;&#x6A21;&#x578B;&#xFF1A;</p>
<p>&#x653E;&#x5C04;&#x53D8;&#x6362;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x7684;&#x516C;&#x5F0F;&#x8868;&#x793A;&#x6805;&#x683C;&#x56FE;&#x4E0A;&#x5750;&#x6807;&#x548C;&#x5730;&#x7406;&#x5750;&#x6807;&#x7684;&#x5173;&#x7CFB;&#xFF1A;</p>
<p>$$
    \begin{matrix}
    X<em>{geo} = GT(0) + X</em>{pixel} <em> GT(1) + Y_{line} </em> GT(2) \
    Y<em>{geo} = GT(3) + X</em>{pixel} <em> GT(4) + Y_{line} </em> GT(5) \
    \end{matrix}</p>
<p>$$
&#xFF08;$X<em>{ge0}$, $Y</em>{ge0}$&#xFF09;&#x8868;&#x793A;&#x5BF9;&#x5E94;&#x4E8E;&#x56FE;&#x4E0A;&#x5750;&#x6807;&#xFF08;$X<em>{pixel}$, $Y</em>{line}$&#xFF09;&#x7684;&#x5B9E;&#x9645;&#x5730;&#x7406;&#x5750;&#x6807;&#x3002;&#x5BF9;&#x4E00;&#x4E2A;&#x4E0A;&#x5317;&#x4E0B;&#x5357;&#x7684;&#x56FE;&#x50CF;&#xFF0C;GT(2)&#x548C;GT(4)&#x7B49;&#x4E8E;0&#xFF0C; GT(1)&#x662F;&#x50CF;&#x5143;&#x7684;&#x5BBD;&#x5EA6;, GT(5)&#x662F;&#x50CF;&#x5143;&#x7684;&#x9AD8;&#x5EA6;&#x7684;&#x76F8;&#x53CD;&#x6570;&#x3002;&#xFF08;GT(0),GT(3)&#xFF09;&#x5750;&#x6807;&#x5BF9;&#x8868;&#x793A;&#x5DE6;&#x4E0A;&#x89D2;&#x50CF;&#x5143;&#x7684;&#x5DE6;&#x4E0A;&#x89D2;&#x5750;&#x6807;&#x3002;</p>
<p> &#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x653E;&#x5C04;&#x53D8;&#x6362;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5F97;&#x5230;&#x56FE;&#x4E0A;&#x6240;&#x6709;&#x50CF;&#x5143;&#x5BF9;&#x5E94;&#x7684;&#x5730;&#x7406;&#x5750;&#x6807;&#x3002;</p>
<p>&#x597D;&#x4E86;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x8BA1;&#x7B97;&#x5BF9;&#x4E8E;&#x4E0A;&#x9762;&#x7684;&#x516D;&#x53C2;&#x6570;&#xFF0C;&#x6211;&#x4EEC;&#x4E3B;&#x8981;&#x9700;&#x8981;&#x8BA1;&#x7B97;&#x91CD;&#x6295;&#x5F71;&#x4EE5;&#x540E;&#x56FE;&#x50CF;&#x5DE6;&#x4E0A;&#x89D2;&#x7684;&#x5750;&#x6807;&#xFF08;&#x6700;&#x5C0F;&#x7684;X&#x5750;&#x6807;&#x503C;&#x548C;&#x6700;&#x5927;&#x7684;Y&#x5750;&#x6807;&#x503C;&#xFF09;&#xFF0C;&#x8FD9;&#x4E2A;&#x8F6C;&#x6362;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>osr.CoordinateTransformation</code>&#x7C7B;&#x8FDB;&#x884C;&#xFF0C;&#x4E0B;&#x9762;&#x7ED9;&#x51FA;&#x5B9E;&#x73B0;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code class="lang-Python"><span class="hljs-keyword">from</span> osgeo <span class="hljs-keyword">import</span> gdal
<span class="hljs-keyword">from</span> osgeo <span class="hljs-keyword">import</span> osr

<span class="hljs-comment"># root_ds = gdal.Open(&apos;/Users/tanzhenyu/Resources/DataWare/MODIS/MOD09A1.A2017361.h28v06.006.2018005034659.hdf&apos;)</span>
<span class="hljs-comment"># # &#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x662F;&#x4E00;&#x4E2A;list&#xFF0C;list&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#x662F;&#x4E00;&#x4E2A;tuple&#xFF0C;&#x6BCF;&#x4E2A;tuple&#x4E2D;&#x5305;&#x542B;&#x4E86;&#x5BF9;&#x6570;&#x636E;&#x96C6;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x5143;&#x6570;&#x636E;&#x7B49;&#x7684;&#x63CF;&#x8FF0;&#x4FE1;&#x606F;</span>
<span class="hljs-comment"># # tuple&#x4E2D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x63CF;&#x8FF0;&#x7684;&#x662F;&#x6570;&#x636E;&#x5B50;&#x96C6;&#x7684;&#x5168;&#x8DEF;&#x5F84;</span>
<span class="hljs-comment"># ds_list = root_ds.GetSubDatasets()</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># # &#x53D6;&#x51FA;&#x7B2C;1&#x4E2A;&#x6570;&#x636E;&#x5B50;&#x96C6;&#xFF08;MODIS&#x53CD;&#x5C04;&#x7387;&#x4EA7;&#x54C1;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x6CE2;&#x6BB5;&#xFF09;&#x8FDB;&#x884C;&#x8F6C;&#x6362;</span>
<span class="hljs-comment"># # &#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8F93;&#x51FA;&#x6570;&#x636E;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x8F93;&#x5165;&#x6570;&#x636E;&#xFF0C;&#x540E;&#x9762;&#x53EF;&#x4EE5;&#x8DDF;&#x591A;&#x4E2A;&#x53EF;&#x9009;&#x9879;</span>
<span class="hljs-comment"># gdal.Warp(&apos;reprojection.tif&apos;, ds_list[0][0], dstSRS=&apos;EPSG:32649&apos;)</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># # &#x5173;&#x95ED;&#x6570;&#x636E;&#x96C6;</span>
<span class="hljs-comment"># root_ds = None</span>


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">reproject</span><span class="hljs-params">(src_file, dst_file, p_width, p_height, epsg_to)</span>:</span>
    <span class="hljs-string">&quot;&quot;&quot;
    :param src_file: &#x8F93;&#x5165;&#x6587;&#x4EF6;
    :param dst_file: &#x8F93;&#x51FA;&#x6587;&#x4EF6;
    :param p_width: &#x8F93;&#x51FA;&#x56FE;&#x50CF;&#x50CF;&#x7D20;&#x5BBD;&#x5EA6;
    :param p_height: &#x8F93;&#x51FA;&#x56FE;&#x50CF;&#x50CF;&#x7D20;&#x9AD8;&#x5EA6;
    :param epsg_to: &#x8F93;&#x51FA;&#x56FE;&#x50CF;EPSG&#x5750;&#x6807;&#x4EE3;&#x7801;
    :return:
    &quot;&quot;&quot;</span>
    <span class="hljs-comment"># &#x9996;&#x5148;&#xFF0C;&#x8BFB;&#x53D6;&#x8F93;&#x5165;&#x6570;&#x636E;&#xFF0C;&#x7136;&#x540E;&#x83B7;&#x5F97;&#x8F93;&#x5165;&#x6570;&#x636E;&#x7684;&#x6295;&#x5F71;&#xFF0C;&#x653E;&#x5C04;&#x53D8;&#x6362;&#x53C2;&#x6570;&#xFF0C;&#x4EE5;&#x53CA;&#x56FE;&#x50CF;&#x5BBD;&#x9AD8;&#x7B49;&#x4FE1;&#x606F;</span>
    src_ds = gdal.Open(src_file)
    src_srs = osr.SpatialReference()
    src_srs.ImportFromWkt(src_ds.GetProjection())

    srs_trans = src_ds.GetGeoTransform()
    x_size = src_ds.RasterXSize
    y_size = src_ds.RasterYSize
    d_type = src_ds.GetRasterBand(<span class="hljs-number">1</span>).DataType

    <span class="hljs-comment"># &#x83B7;&#x5F97;&#x8F93;&#x51FA;&#x6570;&#x636E;&#x7684;&#x6295;&#x5F71;&#xFF0C;&#x5EFA;&#x7ACB;&#x4E24;&#x4E2A;&#x6295;&#x5F71;&#x76F4;&#x63A5;&#x7684;&#x8F6C;&#x6362;&#x5173;&#x7CFB;</span>
    dst_srs = osr.SpatialReference()
    dst_srs.ImportFromEPSG(epsg_to)
    tx = osr.CoordinateTransformation(src_srs, dst_srs)

    <span class="hljs-comment"># &#x8BA1;&#x7B97;&#x8F93;&#x51FA;&#x56FE;&#x50CF;&#x56DB;&#x4E2A;&#x89D2;&#x70B9;&#x7684;&#x5750;&#x6807;</span>
    (ulx, uly, _) = tx.TransformPoint(srs_trans[<span class="hljs-number">0</span>], srs_trans[<span class="hljs-number">3</span>])
    (urx, ury, _) = tx.TransformPoint(srs_trans[<span class="hljs-number">0</span>] + srs_trans[<span class="hljs-number">1</span>] * x_size, srs_trans[<span class="hljs-number">3</span>])
    (llx, lly, _) = tx.TransformPoint(srs_trans[<span class="hljs-number">0</span>], srs_trans[<span class="hljs-number">3</span>] + srs_trans[<span class="hljs-number">5</span>] * y_size)
    (lrx, lry, _) = tx.TransformPoint(srs_trans[<span class="hljs-number">0</span>] + srs_trans[<span class="hljs-number">1</span>] * x_size + srs_trans[<span class="hljs-number">2</span>] * y_size,
                                      srs_trans[<span class="hljs-number">3</span>] + srs_trans[<span class="hljs-number">4</span>] * x_size + srs_trans[<span class="hljs-number">5</span>] * y_size)

    min_x = min(ulx, urx, llx, lrx)
    max_x = max(ulx, urx, llx, lrx)
    min_y = min(uly, ury, lly, lry)
    max_y = max(uly, ury, lly, lry)

    <span class="hljs-comment"># &#x521B;&#x5EFA;&#x8F93;&#x51FA;&#x56FE;&#x50CF;&#xFF0C;&#x9700;&#x8981;&#x8BA1;&#x7B97;&#x8F93;&#x51FA;&#x56FE;&#x50CF;&#x7684;&#x5C3A;&#x5BF8;&#xFF08;&#x91CD;&#x6295;&#x5F71;&#x4EE5;&#x540E;&#x56FE;&#x50CF;&#x7684;&#x5C3A;&#x5BF8;&#x4F1A;&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF09;</span>
    driver = gdal.GetDriverByName(<span class="hljs-string">&apos;GTiff&apos;</span>)
    dst_ds = driver.Create(dst_file,
                           int((max_x - min_x) / p_width),
                           int((max_y - min_y) / p_height),
                           <span class="hljs-number">1</span>, d_type)
    dst_trans = (min_x, p_width, srs_trans[<span class="hljs-number">2</span>],
                 max_y, srs_trans[<span class="hljs-number">4</span>], -p_height)

    <span class="hljs-comment"># &#x8BBE;&#x7F6E;GeoTransform&#x548C;Projection&#x4FE1;&#x606F;</span>
    dst_ds.SetGeoTransform(dst_trans)
    dst_ds.SetProjection(dst_srs.ExportToWkt())
    <span class="hljs-comment"># &#x8FDB;&#x884C;&#x6295;&#x5F71;&#x8F6C;&#x6362;</span>
    gdal.ReprojectImage(src_ds, dst_ds,
                        src_srs.ExportToWkt(), dst_srs.ExportToWkt(),
                        gdal.GRA_Bilinear)
    dst_ds.GetRasterBand(<span class="hljs-number">1</span>).SetNoDataValue(<span class="hljs-number">0</span>)  <span class="hljs-comment"># &#x8BBE;&#x7F6E;NoData&#x503C;</span>
    dst_ds.FlushCache()

    <span class="hljs-keyword">del</span> src_ds
    <span class="hljs-keyword">del</span> dst_ds


<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&apos;__main__&apos;</span>:
    src_file = <span class="hljs-string">&apos;HDF4_EOS:EOS_GRID:&quot;MOD09A1.A2017361.h28v06.006.2018005034659.hdf&quot;:MOD_Grid_500m_Surface_Reflectance:sur_refl_b01&apos;</span>
    dst_file = <span class="hljs-string">&apos;reprojection.tif&apos;</span>
    reproject(src_file, dst_file, <span class="hljs-number">450</span>, <span class="hljs-number">450</span>, <span class="hljs-number">32649</span>)
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="读取HDF或者NetCDF格式的栅格数据.html" class="navigation navigation-prev " aria-label="Previous page: 读取HDF或者NetCDF格式的栅格数据">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="栅格数据裁剪.html" class="navigation navigation-next " aria-label="Next page: 栅格数据裁剪">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"栅格数据投影转换","level":"1.4.2.5","depth":3,"next":{"title":"栅格数据裁剪","level":"1.4.2.6","depth":3,"path":"GDAL空间数据处理/GDAL数据基本操作/栅格数据裁剪.md","ref":"GDAL空间数据处理/GDAL数据基本操作/栅格数据裁剪.md","articles":[]},"previous":{"title":"读取HDF或者NetCDF格式的栅格数据","level":"1.4.2.4","depth":3,"path":"GDAL空间数据处理/GDAL数据基本操作/读取HDF或者NetCDF格式的栅格数据.md","ref":"GDAL空间数据处理/GDAL数据基本操作/读取HDF或者NetCDF格式的栅格数据.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"GDAL空间数据处理/GDAL数据基本操作/栅格数据投影转换.md","mtime":"2019-03-22T18:52:30.713Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-03-22T20:04:12.549Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

